import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [
  { // 登录
    name: 'login',
    path: '/login',
    component: () => import('@/views/login')
  },
  { // 底部标签栏
    path: '/',
    component: () => import('@/views/tab-bar'),
    children: [
      { // 首页推荐视频
        name: 'recommond',
        path: '', // 默认子路由
        component: () => import('@/views/recommond')
      },
      { // 我的
        name: 'my',
        path: '/my',
        component: () => import('@/views/my')
      },
      { // 关注人的视频
        name: 'focus',
        path: '/recommond',
        component: () => import('@/views/focus')
      },
      { // 消息
        name: 'message',
        path: '/message',
        component: () => import('@/views/message')
      },
      { // 拍摄
        name: 'shootvideo',
        path: '/shootvideo',
        component: () => import('@/views/shootvideo')
      }
    ]
  },
  {
    path: '/search',
    component: () => import('@/views/search')
  },
  { // 用户资料
    name: 'user-profile',
    path: '/user/profile',
    component: () => import('@/views/user-profile')
  },
  { // 用户资料
    name: 'user',
    path: '/user/:userid',
    component: () => import('@/views/user-page'),
    props: true,
    meta: { requiresAuth: true }
  },
  { // 用户资料
    name: 'userVideo',
    path: '/user/:userid/:videoType/:videoid',
    component: () => import('@/views/video-list'),
    props: true
  },
  { // 用户资料
    path: '/user/:userid/follow',
    component: () => import('@/views/user-follow'),
    props: true,
    meta: { requiresAuth: true }
  },
  { // 用户消息详情
    name: 'userChat',
    path: '/user/message/:messageid',
    component: () => import('@/views/chat-page'),
    props: true,
    meta: { requiresAuth: true }
  },
  { // 用户消息详情
    name: 'map',
    path: '/map/:key',
    component: () => import('@/views/map'),
    props: true,
    meta: { requiresAuth: true }
  }
]

const router = new VueRouter({
  routes
})

export default router
